#include <bits/stdc++.h>
using namespace std;

// #define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

typedef long long LL;

const int N = 3e5+5, M = 8;

int a[N][M], n, m;
int ax, ay;
bool check(int x)
{
	static int mp[1 << M];

	memset(mp, 0, sizeof mp);

	for (int i=0; i<n; ++i)
	{
		int xx = 0;
		for (int j=0; j<m; ++j)
		{
			if (a[i][j] >= x)
			{
				xx |= 1 << j;
			}
		}
		mp[xx] = i+1;
	}

	int tot = 0;
	static int t[1 << M];
	for (int i=0; i<(1<<m); ++i)
		if (mp[i]) t[tot++] = i;

	if (x == 3)
		for (int i=0; i<tot; ++i)
			dbg(i, t[i]);

	for (int i=0; i<tot; ++i)
		for (int j=i; j<tot; ++j)
			if ((t[i] | t[j]) == (1<<m)-1)
			{
				ax = mp[t[i]];
				ay = mp[t[j]];
				return true;
			}
	return false;
}

int main(int argc, char const *argv[])
{
	scanf("%d%d", &n, &m);
	for (int i=0; i<n; ++i)
	for (int j=0; j<m; ++j)
		scanf("%d", &a[i][j]);
	int l = 0, r = 1e9+1;
	ax = ay = 1;
	while (l < r-1)
	{
		int m = (l+r) >> 1;
		if (check(m)) l = m;
		else r = m;
	}
	dbg(l);
	printf("%d %d\n", ax, ay);
	return 0;
}